package com.kabigon.multiverse.controller;

import com.kabigon.multiverse.vo.ValidVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Email;

/**
 * @author xu.biao
 * @version v1.0
 * @Package com.kabigon.multiverse.controller
 * @data 2022/2/20 23:07
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/valid")
public class ValidController {

    /**
     * 模拟requestBody校验
     * @param validVo
     * @return string
     */
    @PostMapping("/test1")
    public String test1(@Validated @RequestBody ValidVo validVo) {
        log.info("validVo is {}", validVo);
        return "test1 valid success";
    }

    /**
     * form校验
     * @param validVo
     * @return string
     */
    @PostMapping("/test2")
    public String test2(@Validated ValidVo validVo) {
        log.info("validVo is {}", validVo);
        return "test2 valid success";
    }

    /**
     * 单参数校验
     * @param email
     * @return string
     */
    @PostMapping("/test3")
    public String test3(@Email String email) {
        log.info("eamil is {}", email);
        return "eamil valid success";
    }



}
